package com.ctrip.config;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by li_wb on 2017/8/24.
 */
public class HandlerExceptionToViewResolver implements HandlerExceptionResolver {
    @Override
    public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object o, Exception e) {
        System.out.println("=============================HandlerExceptionToViewResolver====================================================");
        System.out.println(e.toString());
        try {
            response.getWriter().write("{\"from\":\"HandlerExceptionToViewResolver\"}");
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        return null;
    }
}
